import React, { Component } from 'react';
import "../../../components/MySwiper/myswiper.css"
import service from '../../../api';
import {List,InfiniteScroll,PullToRefresh} from 'antd-mobile'
import { sleep } from 'antd-mobile/es/utils/sleep'



import  Search  from './search/index';
import MySwiper from '../../../components/MySwiper/swiper';
import Cate from './cate';
import Seckill from "./seckill";
import Recommend from "./recommend";




class home extends Component{
    constructor(){
        super ();
        this.state={
            swiperlist:[]
        }
    }
    

    // 发请求，获取轮播图
    async componentDidMount(){
        var res = await service.banner.banner_list({})
        console.log(res.data);
        
        this.setState({swiperlist:res.data.data}) 
    }

    render() {
        return (
            <div className='home'>
                    {/* 搜索框 */}
                    <Search/>
                    <PullToRefresh>
                    {/* 轮播图 */}
                    <MySwiper swiperlist={this.state.swiperlist} />
                    {/* 分类 */}
                    <Cate/>
                    {/* 秒杀 */}
                    <Seckill/>
                    {/* 推荐列表 */}
                    <Recommend/>
                    {/* 上拉加载, 只有hasMore为true 才会加载下一页 */}
                    <InfiniteScroll loadMore={ this.loadMore } hasMore={this.state.hasMore} />
                </PullToRefresh>
            </div>
        );
    }
}

export default home;